test(e2e): add API client tests#192
Conversation
941ab91 to
45b546d
Compare
There was a problem hiding this comment.
Pull request overview
Adds new AVA-based E2E tests that exercise the low-level APIClient directly and validate response payload structure, intended to catch backend breaking changes earlier at the SDK boundary.
Changes:
- Added functional E2E tests for
getFeatureFlags,getSegmentUsers, andgetEvaluation. - Added a “deep schema validation” E2E suite with bottom-up assertions for nested response objects.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| e2e/api_client.ts | Functional E2E tests for core APIClient endpoints. |
| e2e/api_client_schema.ts | Deep schema assertions for APIClient responses (features, segment users, evaluation). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@cre8ivejp please help me to take a look Note: |
c9af562 to
847e011
Compare
91ac0eb to
1ebd781
Compare
Add E2E API client tests and update config Populate ava-e2e.config.mjs env vars with dev API endpoint, scheme, and example client/server keys, and add new end-to-end tests and plan: - e2e/api_client.ts: behavioral E2E tests for APIClient (getFeatureFlags, getSegmentUsers, getEvaluation). - e2e/api_client_schema.ts: schema validation tests with composable assert helpers that verify presence and types of nested response fields (features, rules, strategies, segment users, evaluations, etc.). - plan-addFieldPresenceAssertionsSchema.prompt.md: plan describing the bottom-up approach for adding field presence assertions and verification steps. These changes add stricter schema checks to catch silent backend field removals and separate behavioral tests from schema validation. Document API client schema tests Add a header comment to e2e/api_client_schema.ts describing the test suite's purpose and approach. The comment explains that the tests perform deep, bottom-up schema validation of Bucketeer API responses—verifying presence and types of fields including nested objects and arrays—to catch breaking changes or field removals at the SDK level and prevent silent production failures. No functional code changes. fix: schema checks and update Variation type Use empty arrays instead of [''] in getSegmentUsers test calls, and adjust schema assertions to handle optional fields: cast allowed strings, only validate name/description when present, and make reason validation conditional. Also update Variation type to require id and name (make them non-optional) in src/objects/feature.ts. These changes fix false-positive test assumptions and align TypeScript types with expected runtime data. Add rationale for runtime schema tests Expand the header comment in e2e/api_client_schema.ts to explain why runtime schema tests are necessary: JSON.parse yields unknown/any at runtime and TypeScript types are erased at compile time, so a runtime test suite acts as the contract to catch backend field removals or type changes that could otherwise silently break production. e2e: assert forceUpdate and segment users Add assertions and clarifying comments to e2e/api_client.ts: ensure response.forceUpdate is true on initial getFeatureFlags and getSegmentUsers calls (so clients fetch latest data), and assert first.segmentUsers.length > 0 in the segment users test to guarantee a non-empty initial result. Minor formatting tweak. Tighten featureFlagsId assertions in e2e test Replace a loose inequality check with explicit assertions: verify featureFlagsId is a string and has length > 0. This makes the test more precise and ensures the response field is both the correct type and non-empty.
1ebd781 to
4b71e43
Compare
close #86
This pull request adds comprehensive end-to-end (E2E) test suites for the Bucketeer API client, focusing on:
The new tests ensure that API endpoints return the expected fields and data types, and that any breaking changes in the backend are caught early. The most important changes are grouped below:
refs: https://github.com/bucketeer-io/go-server-sdk/blob/master/test/e2e/api_test.go
E2e tests passed https://github.com/bucketeer-io/node-server-sdk/actions/runs/24231732798/job/70744660423